package ru.myrtle.umf.query.condition;

public abstract class UBooleanAdapter implements UValueAdapter<Boolean> {

    /**
     * The simplest <code>BooleanAdapter</code> implementation that represents
     * the case when the argument object to adapt is a <code>Boolean</code>
     * object itself.
     */
    public static final UBooleanAdapter DEFAULT = new UBooleanAdapter() {

        @Override
        public Boolean getBoolean(Object object) {
            return (Boolean) object;
        }
    };

    /**
     * Extracts from/Adapts the argument object to a <code>Boolean</code>
     *
     * @param object
     *            The argument object to adapt to a <code>Boolean</code> by
     *            this adapter
     * @return Boolean the <code>Boolean</code> object representation of the argument object
     */
    public abstract Boolean getBoolean(Object object);

    public Boolean adapt(Object value) {
        return getBoolean(value);
    }
}